package com.nearby.demand.ui;

import android.graphics.Point;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.auto.layout.lib.AutoLayoutActivity;
import com.nearby.demand.R;
import com.nearby.demand.action.Action;
import com.nearby.demand.action.ActionView;
import com.nearby.demand.action.BackAction;
import com.nearby.demand.action.DrawerAction;
import com.nearby.demand.action.RevealColorView;
import com.nearby.demand.widget.sand.TagCloudView;
import com.nearby.demand.widget.sand.ViewTagsAdapter;

/**
 * Created by Administrator on 2016/home_1/8.
 */
public class test extends AutoLayoutActivity {
    private ViewTagsAdapter viewTagsAdapter;
    private static final int[] COLORS = {R.color.orange, R.color.orange, R.color.orange};
    TagCloudView tagCloudView;
    ActionView actionView;

    RevealColorView revealColorView;
    int i = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.test);
//        tagCloudView = (TagCloudView) findViewById(R.id.tag_cloud);
//        tagCloudView.setBackgroundColor(Color.LTGRAY);
//        viewTagsAdapter = new ViewTagsAdapter();
//        tagCloudView.setAdapter(viewTagsAdapter);
        Button bautton1 = (Button) findViewById(R.id.bautton1);
        Button bautton2 = (Button) findViewById(R.id.bautton2);
        actionView = (ActionView) findViewById(R.id.ac);
        revealColorView = (RevealColorView) findViewById(R.id.rcv);
        bautton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                reveal(v, R.color.orange);
//                 setAction(new CloseAction(), 1);//x
                setAction(new BackAction(), 1);//箭头
            }
        });
        bautton2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                hide(v);
//                setAction(new PlusAction(), 1);//+
                setAction(new DrawerAction(), 0);//菜单
//
            }
        });


    }


    private Point getLocationInView(View paramView1, View paramView2) {
        int[] arrayOfInt1 = new int[2];
        paramView1.getLocationOnScreen(arrayOfInt1);
        int[] arrayOfInt2 = new int[2];
        paramView2.getLocationOnScreen(arrayOfInt2);
        arrayOfInt2[0] = (arrayOfInt2[0] - arrayOfInt1[0] + paramView2.getWidth() / 2);
        arrayOfInt2[1] = (arrayOfInt2[1] - arrayOfInt1[1] + paramView2.getHeight() / 2);
        return new Point(arrayOfInt2[0], arrayOfInt2[1]);
    }

    private long animationDuration = 420L;
    private int backgroundColor = R.color.orange;

    private void hide(View paramView) {
        Point localPoint = getLocationInView(this.revealColorView, paramView);
        this.revealColorView.hide(localPoint.x, localPoint.y, this.backgroundColor, 0, this.animationDuration, null);

    }

    private void reveal(View paramView, int paramInt) {
        Point localPoint = getLocationInView(this.revealColorView, paramView);
        this.revealColorView.reveal(localPoint.x, localPoint.y, paramInt, 0, this.animationDuration, null);

    }

    private void setAction(Action paramAction, int paramInt) {

        actionView.setAction(paramAction, paramInt);
    }

}
